/***********************************************************************
 * Module:  Note.java
 * Author:  Voja
 * Purpose: Defines the Class Note
 ***********************************************************************/

package model.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "note")
public class Note implements Serializable{

   private static final long serialVersionUID = -7932400001573202000L;

   @Id
   @GeneratedValue(strategy = IDENTITY)
   @Column(name = "note_id", unique = true, nullable = false)
   private Integer id;
   
   @Column(name = "note_caption", unique = false, nullable = true)
   private String  caption;
   
   @Column(name = "note_width", unique = false, nullable = true)
   private Integer width;
   
   @Column(name = "note_height", unique = false, nullable = true)
   private Integer height;
   
   @Column(name = "note_x", unique = false, nullable = true)
   private Integer x;
   
   @Column(name = "note_y", unique = false, nullable = true)
   private Integer y;
   
   @ManyToOne(fetch=FetchType.EAGER)
   @JoinColumn(name = "photo_id", referencedColumnName = "photo_id", nullable = false)
   private Photo photo;

	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getCaption() {
		return caption;
	}
	
	public void setCaption(String caption) {
		this.caption = caption;
	}
	
	public Integer getWidth() {
		return width;
	}
	
	public void setWidth(Integer width) {
		this.width = width;
	}
	
	public Integer getHeight() {
		return height;
	}
	
	public void setHeight(Integer height) {
		this.height = height;
	}
	
	public Integer getX() {
		return x;
	}
	
	public void setX(Integer x) {
		this.x = x;
	}
	
	public Integer getY() {
		return y;
	}
	
	public void setY(Integer y) {
		this.y = y;
	}
	
	public Photo getPhoto() {
		return photo;
	}
	
	public void setPhoto(Photo photo) {
		this.photo = photo;
	}
	
	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String toString() {
		return "Note [id=" + id + "]";
	}
   
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof Note))
			return false;
		return ((Note)obj).getId().intValue()==getId().intValue();
	}
}